package com.aisile.manager.controller;

import com.aisile.entity.PageResult;
import com.aisile.entity.Result;
import com.aisile.manager.TemplateService;
import com.aisile.pojo.TbTypeTemplate;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/temp")
public class TemplateController {
    @Reference
    TemplateService templateService;

    @RequestMapping("findPage")
    public PageResult findPageList(int page, int rows, @RequestBody TbTypeTemplate tbTypeTemplate){

        return templateService.findPage(page,rows,tbTypeTemplate);
    }
    @RequestMapping("/save")
    public Result save(@RequestBody TbTypeTemplate tbTypeTemplate){
        try {
            templateService.insert(tbTypeTemplate);
            return new Result(true,"添加成功");
        }catch (Exception e){

            return  new Result(false,"添加失败");
        }
    }
    @RequestMapping("/delete")
    public Result deleteAll(Long[] ids){
        try {
            templateService.delete(ids);
            return new Result(true,"删除成功");
        }catch (Exception e){

            return  new Result(false,"删除失败");
        }
    }
   @RequestMapping("/findOne")
    public TbTypeTemplate findOne(Long id){

        return templateService.findOneTemplate(id);
   }
   @RequestMapping("/update")
   public Result updateTemplate(@RequestBody TbTypeTemplate tbTypeTemplate){
       try {
           templateService.update(tbTypeTemplate);
           return new Result(true,"添加成功");
       }catch (Exception e){

           return  new Result(false,"添加失败");
       }
   }

}
